package com.fxkj.cloud.drms.infra.mq.mqtt.sender;

import com.fxkj.cloud.dbs.common.constants.DataType;
import com.fxkj.cloud.dbs.common.model.linkage.KvDTO;
import com.fxkj.cloud.drms.domain.mqtt.CommandKv;
import lombok.Data;

import java.io.Serializable;

/**
 * <p>description: </p>
 * @author ww
 * @date 2025/3/25 10:47
 */
@Data
public class MqttCommandKv implements Serializable {
    private String key;
    private Object value;

    public MqttCommandKv() {
    }

    public MqttCommandKv(String key, Object value) {
        this.key = key;
        this.value = value;
    }

    public static MqttCommandKv create(CommandKv commandKv) {
        return new MqttCommandKv(commandKv.attributeKey().getKey(), commandKv.value());
    }

    //todo 这里没法获取到attributeCode 的数据类型,不知道嵌入式接入是否有问题
    public static MqttCommandKv create(KvDTO kvDTO) {
        return new MqttCommandKv(kvDTO.attributeCode(), kvDTO.value());
    }
}
